/**
 * 根据点击树节点的id查看
 */
(function () {
	var catemainADDParam = {
		saveSuccess: function (json) {
			if (json.status == "0") {
				var index = parent.layer.getFrameIndex(window.name);
				parent.layer.msg("新增成功");
				parent.layer.close(index);
			} else {
				parent.layer.msg(json.message);
			}
		},
		bindEven : function(){
			var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
			$("#check").unbind().on("click", function () {
				parent.layer.ready(function () {
					var index = parent.layer.getFrameIndex(window.name);
					parent.parindex = index;
					//增加编辑
					parent.layer.open({
						type: 2,
						//skin: 'layui-layer-lan',
						title: "选择人员",
						fix: false,
						shadeClose: true,
						maxmin: true,
						area: ['1000px', '600px'],
						content: 'html/updateemployee.html?type=subpage',
					});
				});
			});

			//新增节点
			$("#save").unbind().on("click", function () {
				var nodeid = parent.nodeid;
				var knowledge_category_name = $("#thisbefornodename2").val();
				var len = 0;
				for (var i = 0; i < knowledge_category_name.length; i++) {
					if (knowledge_category_name.charCodeAt(i) > 127 || knowledge_category_name.charCodeAt(i) == 94) {
						len += 2;
					} else {
						len++;
					}
				}
				var liststatus = $("#liststatus").val();
				var administrator = $("#administratorid").val();
				if (knowledge_category_name == "") {
					layer.msg("请填写商品名称");
				} else if (administrator == "") {
					layer.msg("请选择商品类别管理员");
				} else if (len > 60) {
					layer.msg("你的输入过长，请重新输入！");
				} else {
					var url = "/PCKnowledgeCategoryEntity/insertCategory";
					var data = {
						"fw_parent": nodeid,
						"knowledge_category_name": knowledge_category_name,
						"pk_user": administrator,
						"sealmark": liststatus
					};
					common.interfaceAjaxFunction(url, data, catemainADDParam.saveSuccess);
				}
			});
			
			// 取消按钮
			$("#cancleButtonLayer").unbind().on("click", function () {
				parent.layer.close(index);
			});
		}
	};
	
	$(document).ready(function () {
		//事件绑定
		catemainADDParam.bindEven();
		//用友信息记录
		var nodeid = parent.nodeid;
		var currentNodeName = parent.currentNodeName;
		if (nodeid != null) {
			$("#currentNodeName").val(currentNodeName);
		} else if (currentNodeName != null) {
			$("#currentNodeName").val(currentNodeName);
		} else {
			$("#currentNodeName").val("无");
		}
		//高度初始化
		//catemainParam.initPageHeight();
	});
})();

/**
 * 验证输入框字符长度
 */
/*var searchKeyList = function(obj){
	//输入值
	var value = $(obj).val();
	 var len = 0;    
	    for (var i=0; i<value.length; i++) {    
	        if (value.charCodeAt(i)>127 || value.charCodeAt(i)==94) {    
	             len += 2;    
	         } else {    
	             len ++;    
	         }    
	     } 
	 
	  if(len>8){
		  $("#thisbefornodename2").attr("readonly",true);
	  }
			
			
};
document.onkeydown=function(event){
	   var e = event || window.event || arguments.callee.caller.arguments[0];
	   if(e && e.keyCode==8){ // 按 删除键
          $("#thisbefornodename2").attr("readonly",false);
       }
};*/